package org.example.sportdemo.controller;

import org.example.sportdemo.entity.User;
import org.example.sportdemo.service.UserService;
import org.example.sportdemo.utils.R;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/gymlogin")
    @ResponseBody
    public R login(String username,String password){
        User loginUser = userService.login(username,password);
        if (loginUser != null){
            return R.ok();
        }
        else {
            return R.error("用户名或密码错误");
        }

    }
}
